package com.hooper.dict.test;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.Map;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2022/09/26/23:49
 */
public class ExcelListener extends AnalysisEventListener<User> {

    //一行一行读取excel中的内容，从第二行开始
    @Override
    public void invoke(User user, AnalysisContext analysisContext) {
        System.out.println(user);
    }

    //读取第一行数据
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        super.invokeHeadMap(headMap, context);
        System.out.println("第一列："+headMap.get(0) + "\t第二列：" + headMap.get(1));
    }

    //读完后执行
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("读取完毕！");
    }
}
